

#include "iostream"
#include "memory"
#include "string"
#include "queue"
using namespace std;




#ifdef TEST_SHARE_PTR
class Car
{

public:
    string name;
    Car(string n):name(n){};
    ~Car(){};
    virtual void getName(){cout<<name<<endl;}
};

class Aodi:public Car
{
public:
    Aodi(string n):Car(n){};
    ~Aodi(){};
    virtual void getName(){cout<<"This is Aodi"<<endl;}
};

class AodiA5 :public Aodi
{
public:
    AodiA5(string name):Aodi(name){};
    string new_feature;
};

queue<shared_ptr<Car>> queueforcar;


void func()
{
    auto ptr = make_shared<Aodi>("A");
    cout<<__LINE__<<":"<<ptr.use_count()<<endl; //1
    queueforcar.push(ptr);
    cout<<__LINE__<<":"<<ptr.use_count()<<endl; //1
}
int main()
{    
    func();
    cout<<__LINE__<<":"<< queueforcar.front().use_count()<<endl; //1
    auto car = queueforcar.front();
    cout<<__LINE__<<":"<<car.use_count()<<endl; //1
    auto car2 = make_shared<Aodi>(car->name);
    auto a5 = make_shared<AodiA5>(car->name);
    queueforcar.pop();
    cout<<__LINE__<<":"<<car.use_count()<<endl; //1
    cout<<__LINE__<<":"<<car2.use_count()<<endl; //1
    cout<<__LINE__<<":"<<a5.use_count()<<endl; //1
    queueforcar.push(car2);
    queueforcar.push(a5);
}
#endif
